const mongoose = require("mongoose")
const baseModals = require("./base-model")
const md5 = require("../util/md5")
//定义集合模型的文档结构
const userSchema = new mongoose.Schema({
  name: {
    type: String,
    required: false
  },
  email: {
    type: String,
    required: false,
  },
  password: {
    type: String,
    required: false,
    required: true,
    set: (value) => md5(value),
    select: false //不返回密码
  },
  gender: {
    type: String,
    enum: ['男', '女'],
    default: '男'
  },
  age: {
    type: Number,
    required: false
  },
  phone: {
    type: String,
    required: false
  },
  address: {
    type: String,
    required: false
  },
  createAt: baseModals.createAt,
  updateAt: baseModals.updateAt

})
module.exports = userSchema
// //创建集合模型
// const User = mongoose.model("users", userSchema)
// module.exports = User